package com.tick;


import com.sun.tools.javac.util.ArrayUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * 描述:
 *
 * @author luzhongfu
 * Created by lucky on 2020-09-27 3:26 PM
 */
public class DualThrust {
    public static void main(String[] args) {
        double high = 4770;
        double close = 4943;
        double low = 4706;
        double open = 4870;
        double diff_high = high - close;

        double diff_low = close - low;

        double k = diff_high > diff_low ? diff_high : diff_low;
        k = k * 0.7;
        System.out.println(k + open);
        System.out.println(open - k);

        List<User> list = new ArrayList<>();
        list.add(new User("18861856677"));

        list.add(new User("3"));

        list.add(new User("1"));
        list.add(new User("5"));
        list.add(new User("6"));
//        List<User> collect = list.stream().sorted(Comparator.comparing(item -> Integer.valueOf(((User) item).getId())).reversed()).collect(Collectors.toList());

        Object[] objects = list.stream().map(User::getId).toArray();
        for (Object object : objects){
            if(object.equals("18861856677")){
                System.out.println(11111);
            }
        }
//        System.out.println(collect);

        User user = new User("1");

        Optional<BigDecimal> reduce = list.stream().map(x -> new BigDecimal(x.getId()))
                .reduce(BigDecimal::add);
        reduce.ifPresent(bigDecimal -> user.setId(bigDecimal.toPlainString()));
        System.out.println(user.getId());
    }

    static class User{
        String id ;

        BigDecimal price;

        public User(String id) {
            this.id = id;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }
    }
}
